<template>
    <!--可以考虑做个dialog-->
    <div>
        <el-input auto-complete="off" clearable v-model="message"></el-input>
        <el-button @click="view">view</el-button>
        <img :src="src" alt="qrCode">
    </div>
</template>

<script>
export default {
    name: "qrCode",
    data() {
        return {
            src: '',
            message: ''
        }
    }, methods: {
        view() {
            const message = this.message;
            if (message && message.length > 0)
                axios({
                    url: '/api/qr/qrCode',
                    method: 'get',
                    params: {message: message},
                    responseType: 'blob',
                }).then(rs => {
                    //这里也是关键,调用window的这个方法URL方法
                    this.src = window.URL.createObjectURL(rs.data);
                })
        }
    }
}
</script>

<style scoped>

</style>